<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Эмулятор звонка телефона</title>
    <script type="text/javascript" src="../js/jquery/jquery.js"></script> 
    <script type="text/javascript" src="../js/dbg.js"></script> 
<script>

var boxLog = null;

$(function(){
    boxLog = $("#boxLog");
    
    $("#btnCheckPhone").bind("click", ring);
    
});


function ring()
{
    var phone = $("#inpPhone").val();
    request(phone);
    log2(dt() + " call from: "+ phone);
}

function request(phone)
{
    $.ajax({
        url: "../../common/call.php?act=call&phone="+phone,
        dataType: 'json',
        success: function(data)
        {
            log2(var_dump(data));
        }
    });
}


function two(num)
{
    if(num < 10)
        return '0' + num;
    else
        return num;
}

function dt()
{
    var t = new Date();
    return two(t.getHours()) +":"+ two(t.getMinutes()) +":"+ two(t.getSeconds());
}

function log2(msg)
{
    boxLog.text(msg + "\n" + boxLog.text());
}

</script>
</head>

<body style="margin: 20px; font-family: Arial, Verdana;">
    <div style="font-size: 22px;">
        <span >Телефон:</span>
        <input id="inpPhone"  style="font-size: 22px;"/>
        <button id="btnCheckPhone" class="large">Звонить</button>
        <br/><br/>
    </div>
    <pre id="boxLog">
    </pre>
</body>
</html>
